<template>
  <guat-page-layout title="积分类型">
    <template #actions>
      <guat-button-group
        :buttons="[
          {
            text: '新增类型',
            internal: $config.$button.PLR,
            permission: $permission.POINT_TYPE_ADD,
            onClick: () => setModalVisible(true),
          },
        ]"
      />
    </template>
    <guat-point-type-table />
    <guat-new-type-modal title="新增类型">
      <guat-new-type-form />
    </guat-new-type-modal>
  </guat-page-layout>
</template>

<script setup lang="ts">
import { createTableColumns } from "./table-config";
import { addTypeFormItemConfig } from "../form-config";

const [GuatPointTypeTable, { setTableData }] = useTable(
  createTableColumns({
    del: handleOnDelete,
    upd: handleOnUpdate,
  })
);
const [GuatNewTypeForm] = useForm(addTypeFormItemConfig);
const [GuatNewTypeModal, { setModalVisible }] = useModal();
const { warning } = useModalNotice();

function handleOnDelete(typeName: string) {
  warning({
    title: "删除确认",
    content: `请确认是否要删除 ${typeName}`,
  });
}

function handleOnUpdate(_record: any) {
  // setFormValue(record);
  setModalVisible(true);
}

onMounted(() => {
  setTableData([
    {
      type: "活动积分",
      time: "2023-04-10 20:23:22",
      status: 0,
    },
    {
      type: "签到积分",
      time: "2023-04-10 20:23:22",
      status: 1,
    },
  ]);
});
</script>

<style scoped></style>
